<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/jsp/declare.jsp" %>

<!DOCTYPE html>
<html>
<head>
	<base href="<%=basePath %>" />
	<title>房间-列表</title>
	<%@ include file="/common/jsp/common.jsp" %>
	
	<script>
	function book(dom, rentType) {
		var roomId = dom.parentNode.parentNode.id;
		if (rentType == 2)//群租
			redirect("mvc/renter/${communityId}/" + roomId + "/bedList.htm");
		else//整租
			redirect("mvc/renter/${communityId}/" + roomId + "/0/order.htm");
	}
	</script>
</head>
<body id="room">
	<div class="picBar">
		<img src="aizu/images/room/room.jpg" />
	</div>
	<div class="address">地址：${address }</div>
	<table border="0" cellspacing="0" borderColor="#DADADA">
		<thead>
			<tr>
				<th>房间名称</th>
				<th>类型</th>
				<th>总床位</th>
				<th>剩余床位</th>
				<th>价格(元)</th>
				<th>状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="room" items="${rooms}">
			<tr id="${room.id }">
				<td>${room.building }${room.unit }${room.room_num }</td>
				<td>${room.rent_type eq 1 ? '整租' : '群租' }</td>
				<td>${!empty room.bed_count ? room.bed_count : 0 }</td>
				<td>${!empty room.bed_surplus_count ? room.bed_surplus_count : 0 }</td>
				<td><fmt:formatNumber value="${!empty room.room_price ? room.room_price : 0 }" pattern="#,#00.#"/></td>
				<td>${room.bed_surplus_count > 0 ? '出租' : '满租' }</td>
				<c:if test="${room.bed_surplus_count gt 0 }">
				<td><button class="edit" onclick="book(this, '${room.rent_type }')">预订</button></td>
				</c:if>
				<c:if test="${room.bed_surplus_count eq 0 }">
				<td><button class="cantEdit">预订</button></td>
				</c:if>
			</tr>
			</c:forEach>
		</tbody>
	</table>
</body>
</html>